package com.devunion.salon.web.bean;

import com.devunion.salon.persistence.Product;

import java.io.Serializable;

/**
 * @author Timoshenko Alexander 14.09.2008 : 0:54:27
 */
public class ProductBean implements Serializable {
    private Long key;
    private String name;
    private Float price;
    private Float taxes;

    public ProductBean(Product product) {
        this.key = product.getId();
        this.name = product.getName();
        this.price = product.getSalePrice();
        this.taxes = product.getLocation().getProductTaxes();
    }

    public Long getKey() {
        return key;
    }

    public String getName() {
        return name;
    }

    public Float getPrice() {
        return price;
    }

    public Float getTaxes() {
        return taxes;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProductBean that = (ProductBean) o;

        if (key != null ? !key.equals(that.key) : that.key != null) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (price != null ? !price.equals(that.price) : that.price != null) return false;
        if (taxes != null ? !taxes.equals(that.taxes) : that.taxes != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (key != null ? key.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (taxes != null ? taxes.hashCode() : 0);
        return result;
    }
}
